package top.oylan.manager.tools.configuration;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import static springfox.documentation.builders.PathSelectors.regex;

@Configuration
@EnableSwagger2
public class SwaggerConfiguration {

    @Bean
    public Docket accessToken(){

        return new Docket(DocumentationType.SWAGGER_2).groupName("api/")
                .select()
                .apis(RequestHandlerSelectors.basePackage("top.oylan.manager.controller.api"))
                .paths(regex("/api/.*"))
                .build()
                .apiInfo(apiInfo());
    }

    private ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                .title("Oylan Api System")
                .termsOfServiceUrl("http://localhost")
                .contact(new Contact("oylan","http://org.aylan.top","itoldi@126.com"))
                .description("接口")
                .version("1.0")
                .build();
    }
}
